package com.lwy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lwy.dao.ResoucesInfoMapper;
import com.lwy.entity.ResoucesInfo;
import com.lwy.service.ResoucesInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;


@Service
public class ResoucesInfoServiceImpl extends ServiceImpl<ResoucesInfoMapper, ResoucesInfo> implements ResoucesInfoService {


    public List<ResoucesInfo> findList(){
        List<ResoucesInfo> resoucesInfos = baseMapper.selectList(new QueryWrapper<ResoucesInfo>().gt("parent_id",0));
        List<ResoucesInfo> resoucesInfos2 = baseMapper.selectList(new QueryWrapper<ResoucesInfo>().eq("parent_id",0));


        for (ResoucesInfo resoucesInfo : resoucesInfos2) {
            List<ResoucesInfo> list = new ArrayList<>();
            for (ResoucesInfo info : resoucesInfos) {
                if(resoucesInfo.getId()==info.getParentId()){
                    list.add(info);
                }
            }
            resoucesInfo.setList(list);
        }
        return resoucesInfos2;
    }



}
